package com.ssm.blog.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.blog.dao.NoticeDAO;
import com.ssm.blog.pojo.Notice;
import com.ssm.blog.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    private NoticeDAO noticeDAO;

    @Override
    public void addNotice(Notice Notice) {
        noticeDAO.addNotice(Notice);
    }

    @Override
    public PageInfo<Notice> getNoticeList(Notice criteria, int page, int pageSize) {
        PageHelper.startPage(page, pageSize, "id desc");
        List<Notice> NoticeList = noticeDAO.getNoticeList(criteria);
        PageInfo<Notice> pageInfo = new PageInfo<>(NoticeList);
        return pageInfo;
    }

    @Override
    public void deleteNotice(Integer id) {
        noticeDAO.deleteNotice(id);
    }
}
